package com.akkainaction.remote.serialize.java.client;

import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.actor.UntypedActor;
import com.akkainaction.remote.serialize.java.po.User;
import com.akkainaction.remote.serialize.java.server.UserServerActor;
import com.typesafe.config.ConfigFactory;

public class UserClientActor extends UntypedActor {

    @Override
    public void onReceive(Object msg) throws Exception {
        if (msg instanceof User) {
            User user = (User) msg;
            System.out.println("UserClientActor 接收到的消息:" + user);
        }
    }

    public static void main(String[] args) {
        ActorSystem system = ActorSystem.create("cliSys", ConfigFactory.load("akka-remote-serialize-client.conf"));
        ActorRef userClientActor = system.actorOf(Props.create(UserClientActor.class), "userClient");
        ActorRef userServerActor = system.actorOf(Props.create(UserServerActor.class), "userServerActor");
        userServerActor.tell("zs",userClientActor);
    }
}
